from collections import defaultdict
from datetime import datetime

fmt = '%Y-%m-%d_%H:%M'

res = defaultdict(int)

with open("history.txt") as f:
    for line in f:
        line = line.strip()
        start, end = line.split(sep=" ")
        day = start.split("_")[0]
        res[day] += (datetime.strptime(end, fmt) - datetime.strptime(start, fmt)).seconds // 60

for key, item in res.items():
    print(key, item)

input()